package com.unlcn.erp.hyc.interfaces.api.schedule;

import com.unlcn.erp.hyc.interfaces.backend.service.CallReceivableCodesService;
import org.joda.time.DateTime;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

/**
 * Created by zhiche024 on 2017/9/22.
 */
public class CallReceivableOrderPort  implements Job{

    private static final Logger LOGGER = LoggerFactory.getLogger(CallReceivableOrderPort.class);

    @Autowired
    private CallReceivableCodesService callReceivableCodesService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        LOGGER.info("CallReceivableOrderPort job startTime {}", DateTime.now().toString("yyyy-MM-dd HH:mm:ss:SSS"));
        try {
            callReceivableCodesService.getCodes();
            callReceivableCodesService.updateArorder();
        }catch (Exception e){
            e.printStackTrace();
            LOGGER.error("CallReceivableOrderPort 定时任务保存失误 error: {}",e);
        }
        LOGGER.info("CallReceivableOrderPort job endTime {}", DateTime.now().toString("yyyy-MM-dd HH:mm:ss.SSS"));
    }
}
